﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace quizzer_linq_3
{
    /**Class: AdminLogin
     * @author Samuel McCravy and Jayson Parks
     * @version 1.1
     * Course : ITEC 4860 Spring 2012
     * Written: March 20, 2012
     * 
     * This Class allows admins to traverse all of the menus available
     * 
     * Purpose: The purpose of this class is to allow admins to get to each of the different menus or be able to logout.
    */

    public partial class AdminLogin : Form
    {

        //This is used to pass the user_id to various forms

        private int user_id;
        
        //This is the default Admin user id

        const int ADMIN_USER_ID = 1000;

        public AdminLogin()
        {
            InitializeComponent();
            user_id = ADMIN_USER_ID;
        }

        public AdminLogin(int user_id)
        {
            this.user_id = user_id;
            InitializeComponent();
            checkForAdmin();
        }

        private void checkForAdmin()
        {
            if (user_id == ADMIN_USER_ID)
            {
                administrationButton.Enabled = true;
                resetPasswordButton.Enabled = true;
            }
            else
            {
                administrationButton.Visible = false;
                resetPasswordButton.Visible = false;
                logoutButton.Location = new System.Drawing.Point(210, 143);
                this.ClientSize = new System.Drawing.Size(363, 240);
            }
        }

        /** Method: administrationButton_Click
         * Goes to the administration menu
         * 
         * @param sender sender of the action
         * @param e event is triggered
        */

        private void administrationButton_Click(object sender, EventArgs e)
        {

            //Sends the user to the administration form

            Administration administrationForm = new Administration();
            this.Hide();
            administrationForm.ShowDialog();
            this.Show();
        }

        /** Method: resetPasswordButton_Click
         * Goes to the ResetPassword menu
         * 
         * @param sender sender of the action
         * @param e event is triggered
        */

        private void resetPasswordButton_Click(object sender, EventArgs e)
        {

            //Sends the user to the reset password form

            Reset_Password resetPasswordForm = new Reset_Password();
            this.Hide();
            resetPasswordForm.ShowDialog();
            this.Show();
        }

        /** Method: setCreatorButton_Click
         * Goes to the Set Creator menu
         * 
         * @param sender sender of the action
         * @param e event is triggered
        */

        private void setCreatorButton_Click(object sender, EventArgs e)
        {
            //Sends the user to the setcreator form

            Set_Creator setCreatorForm = new Set_Creator(user_id);
            this.Hide();
            setCreatorForm.ShowDialog();
            this.Show();
        }

        /** Method: testModeButton_Click
         * Goes to the Game Setup menu
         * 
         * @param sender sender of the action
         * @param e event is triggered
        */


        private void testModeButton_Click(object sender, EventArgs e)
        {
            //Sends the user to the game setup form

            Game_Setup testModeForm = new Game_Setup();
            this.Hide();
            testModeForm.ShowDialog();
            this.Show();
        }

        /** Method: logoutButton_Click
         * @author Samuel McCravy
         * Goes back to the login screen
         * 
         * @param sender sender of the action
         * @param e event is triggered
        */

        private void logoutButton_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        /** Method: creatorButton_Click
         * Goes to the Question Creator menu
         * 
         * @param sender sender of the action
         * @param e event is triggered
        */


        private void creatorButton_Click(object sender, EventArgs e)
        {
            //Sends the user to the question creator form
            QuestionCreatorForm questionCreatorForm;
            if (user_id == 0)
            {
                questionCreatorForm = new QuestionCreatorForm();
            }
            else
            {
                questionCreatorForm = new QuestionCreatorForm(user_id);
            }
            this.Hide();
            questionCreatorForm.ShowDialog();
            this.Show();
        }
    }
}
